package com.test.demo.web.controller;

import com.test.demo.dean.User;
import com.test.demo.service.IUserService;
import com.test.demo.utils.Message;
import com.test.demo.utils.MessageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.xml.crypto.Data;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService userService;

    @GetMapping("query")
    public Message query(String name) {

        List <User> list  = userService.query(name);
        return MessageUtil.success(list);

    }

    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate(User user){
        userService.saveOrUpdate(user);
        return MessageUtil.successs("更新成功");
    }


}
